"""
@File    :   validate.py
@Time    :   2024/04/24 23:14:22
@Author  :   Qrj
@Email   :   923207736@qq.com
@description   :   OAuth2密码模式相关的pydantic验证模型
"""

from pydantic import BaseModel, Field

from src.business.admin.system.oauth2.auth.enums import (
    UserLoginPasswordEncryptTypeEnum,
)
from src.schemas.validate import NoUseEnumValuesBaseValidateSchemaConfigMixin


class SwaggerPasswordCreateDoubleTokenValidateSchema(
    BaseModel, NoUseEnumValuesBaseValidateSchemaConfigMixin
):
    """用于创建Oauth2的swagger专用的密码模式的双Token的验证模型"""

    tenant_id: int = Field(default=..., description="租户ID")
    oauth2_client_client_id: str = Field(
        default=..., min_length=1, max_length=255, description="OAuth2客户端编号"
    )
    oauth2_client_client_secert: str = Field(
        default=..., min_length=1, max_length=255, description="OAuth2客户端密钥"
    )
    username: str = Field(
        default=..., min_length=1, max_length=20, description="登录用户名"
    )
    password: str = Field(
        default=..., min_length=1, max_length=20, description="登录密码(明文)"
    )


class PasswordCreateDoubleTokenValidateSchema(
    BaseModel, NoUseEnumValuesBaseValidateSchemaConfigMixin
):
    """用于创建Oauth2密码模式的双Token的验证模型"""

    tenant_id: int = Field(default=..., description="租户ID")
    oauth2_client_client_id: str = Field(
        default=..., min_length=1, max_length=255, description="OAuth2客户端编号"
    )
    oauth2_client_client_secert: str = Field(
        default=..., min_length=1, max_length=255, description="OAuth2客户端密钥"
    )
    username: str = Field(
        default=..., min_length=1, max_length=20, description="登录用户名"
    )
    password: str = Field(
        default=..., min_length=1, max_length=500, description="登录密码"
    )
    encrypt_type: UserLoginPasswordEncryptTypeEnum = Field(
        default=UserLoginPasswordEncryptTypeEnum.rsa.value,
        description="登录密码的加密方式",
    )
